Skip to main content

This page describes the process to access any ModelPart from the global ModelPart models

Getting a ModelPart

A property of all ModelParts is that you can get a child ModelPart of a parent ModelPart by indexing the parent with the child's name.
models itself is a ModelPart. All bbmodel files in the avatar act as child ModelParts to models.
Everything in the root of a Blockbench project is a child of the bbmodel ModelPart.
After that, parenting follows the parent structure as defined in the Blockbench OUTLINER.
For example the cube RightArm,

model.bbmodel├─ Head│  ├─ Head│  └─ Head Layer└─ RightArm   ├─ RightArm   └─ RightArm Layer

Would be accessed via models.model.RightArm.RightArm

Figura Model Format

Using the Figura Model Format Blockbench plugin you can right click a group/cube/mesh and copy the path to your clipboard.

To use the plugin open Blockbench and go to File in the upper left, and go down to the Plugins... option, you can find Figura Model Format there.

Once the plugin is installed, open the Blockbench project and go back to File and then Convert Project. Choose the Figura Model format and press confirm.

After that's complete you can right click on a group/cube/mesh and copy the path to your clibboard. Note that this path will not include any subfolders the Blockbench model is in.

Storing a ModelPart

As there is nothing special about indexing straight from models all the time (its just another ModelPart), if a specific ModelPart is used multiple times in a script we can store it in a variable for ease of access.

--sets a World parented part to match the player's position and body rotation
local worldPart = models.model.World
function events.RENDER(delta, context)
worldPart:setPos(player:getPos(delta) * 16)
worldPart:setRot(0, -player:getBodyYaw(delta) + 180, 0)
end

BBmodels in subfolders

bbmodel files in subfolders are a special case. For them, the folder itself acts as another ModelPart.

├─ subfolderA│  ├─ Pet.bbmodel│  └─ bow.bbmodel└─ subfolderB   ├─ model.bbmodel   └─ bow.bbmodel

The bbmodel Pet.bbmodel would be accessed by models.subfolderA.Pet.